home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
lib
/
map_continents.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
11KB
|
316 lines
; $Id: map_continents.pro,v 1.19 1997/03/26 00:15:35 dave Exp $
;
; Copyright (c) 1993-1997, Research Systems, Inc. All rights reserved.
; Unauthorized reproduction prohibited.
;+
; NAME:
; MAP_CONTINENTS
;
; PURPOSE:
; The MAP_CONTINENTS procedure draws continental boundaries,
; filled continents, political boundaries, coastlines, and/or rivers,
; over an existing map projection established by MAP_SET. Outlines can
; be drawn in low or high-resolution (if the optional high-resolution
; CIA World Map database is installed). If MAP_CONTINENTS is called
; without any keywords, it draws low-resolution, unfilled continent
; outlines.
;
; MAP_SET must be called before MAP_CONTINENTS to establish the
; projection type, the center of the projection, polar rotation
; and geographic limits.
;
; Keywords not recognized are passed along in _EXTRA to PLOTS and/or
; POLYFILL depending on options requested.
;
; CATEGORY:
; MAPPING
;
; CALLING SEQUENCE:
; MAP_CONTINENTS
;
; INPUTS:
; NONE
;
; INPUT KEYWORD PARAMETERS:
; COASTS -- Set this keyword to draw coastlines, islands, and lakes instead of
; the default continent outlines. Note that if you are using the
; low-resolution map database (if the HIRES keyword is not set), many
; islands are drawn even when COASTS is not set. If you are using the
; hi gh-resolution map database (if the HIRES keyword is set),
; no islands are drawn unless COASTS is set.
; COLOR -- The color index of the lines being drawn.
; COUNTRIES -- Set this keyword to draw political boundaries as of 1993.
; _EXTRA -- Other keywords passed along to PLOTS/POLYFILL depending on
; options selected. Note that command line keywords (like
; MLINETHICK) will take precedence over options specified with
; _EXTRA or their natural names (like THICK).
; FILL_CONTINENTS -- Set this keyword to 1 to fill continent boundaries with
; a solid color. The color is set by the COLOR keyword.
; Set this keyword to 2 to fill continent boundaries with a
; line fill. For line filling, the COLOR, MLINESTYLE,
; MLINETHICK, ORIENTATION, and SPACING keywords can be used
; to control the type of line fill. Any option valid for
; polyfill can also be used (i.e. PATTERN).
; HIRES -- Set this keyword to use high-resolution map data instead of the
; default low-resolution data. This option is only available if you
; have installed the optional high-resolution map datasets. If the
; high-resolution data is not available, a warning is printed and
; the low-resolution data is used instead.
;
; This keyword can be used in conjunction with the COASTS, COUNTRIES,
; FILL_CONTINENTS, and RIVERS keywords.
;
; MLINESTYLE -- The line style of the boundaries being drawn.
; The default is solid lines.
; MLINETHICK -- The thickness of the boundary or fill lines.
; The default thickness is 1.
; ORIENTATION -- Set this keyword to the counterclockwise angle in degrees
; from horizontal that the line fill should be drawn. The
; default is 0. This keyword only has effect if the
; FILL_CONTINENTS keyword is set to 2.
; RIVERS -- Set this keyword to draw rivers.
; SPACING -- Set this keyword to the spacing, in centimeters, for a line fill.
; This keyword only has effect if the FILL_CONTINENTS keyword is
; set to 2. The default is 0.5 centimeters.
; USA -- Set this keyword to draw borders for each state in the United States
; in addition to continental boundaries.
;
; OUTPUT KEYWORD PARAMETERS:
; NONE
;
; OUTPUTS:
; Draws continents, etc. over the current map display.
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; None.
;
; RESTRICTIONS:
; See DESCRIPTION.
;
; DESCRIPTION:
; See PURPOSE.
;
; EXAMPLES:
;
; Draw Low-Resolution continents, with high resolution
; political boundaries.
;
; MAP_SET
; MAP_CONTINENTS
; MAP_CONTINENTS,/hires,/countries
;
; DEVELOPMENT NOTES:
; This version uses !type=3 and uses the NEW (IDL5) map software.
; requires map_struct_append in map_set.pro
;
; MODIFICATION HISTORY:
; SVP, 11/96 ; Added header template.
;
;-
;
; ROUTINES:
; fun map_getindex,indx - read the map database index files
; fun map_do_segments - reads and plots map segments
; fun map_continents - the main routine
; -----------------------------------------------------------------------------
FUNCTION map_getindex,indx, error
;
; Used to read in the index file for
; each map data file. On successful completion, error is set to 0.
;
openr, lun, indx, /xdr, /get_lun, error = error
if error ne 0 then return, 0 ;File not there or unreadable
segments=0L & readu, lun, segments
dx_map=replicate({ fptr:0L, npts:0L,latmax:0.,latmin:0.,$
lonmax:0.,lonmin:0. }, segments )
readu, lun, dx_map & free_lun, lun
free_lun,lun
return, dx_map
END
PRO map_do_segments, fnames, name, hires, bounds, zvalue, extra, POLYFILL=poly
; Output a segment file:
; fnames = [lowresname, hiresname]
; name = description for error message (boundaries, rivers, etc.
; hires = 0 for low res, 1 for hires
; zvalue = Z value for 3D
; bounds = lat/lon bound.
; Polyfill = 0 for lines, 1 for polyfill
; Hires = 1 to do hires, 0 for low
if n_elements(poly) eq 0 then poly = 0
lun = -1
sub = (['low', 'high'])[hires]
fndx = FILEPATH(fnames[hires]+'.ndx', SUBDIR=['resource','maps',sub])
dat = FILEPATH(fnames[hires]+'.dat', SUBDIR=['resource','maps',sub])
ndx = map_getindex(fndx, error) ;OPEN it
if error eq 0 then openr, lun, dat,/xdr,/stream, /get, error = error
if (error ne 0) and hires then begin ;Try low res as a fallback
message, 'High Res Map File: '+name+' not found, trying low res.', /INFO
fndx = FILEPATH(fnames[0]+'.ndx', SUBDIR=['resource','maps','low'])
dat = FILEPATH(fnames[0]+'.dat', SUBDIR=['resource','maps','low'])
ndx = map_getindex(fndx, error) ;OPEN it
endif ;Hires
if lun lt 0 then openr, lun, dat,/xdr,/stream, /get, error = error
if error ne 0 then message, 'Map file:'+fnames[hires]+' not found'
; Output a bunch of segments from a standard format file.
lonmin = bounds[0]
lonmax = bounds[2]
latmin = bounds[1]
latmax = bounds[3]
test_lon = ((lonmax-lonmin) mod 360.) ne 0.0
test_lat = lonmin gt -90. or lonmax lt 90.
; Prune segments if bounds are set.
if test_lon and test_lat then begin
subs = where((ndx.latmin lt latmax) and (ndx.latmax gt latmin) and $
((ndx.lonmin lt lonmax) OR (ndx.lonmax gt lonmin)), count)
if count ne 0 then ndx = ndx(subs)
endif else if test_lon then begin
subs = where((ndx.lonmin lt lonmax) OR (ndx.lonmax gt lonmin), count)
if count ne 0 then ndx = ndx(subs)
endif else if test_lat then begin
subs = where((ndx.latmin lt latmax) and (ndx.latmax gt latmin), count)
if count ne 0 then ndx = ndx(subs)
endif else count = n_elements(ndx)
; ************** Draw the segments ***************************
;
if count gt 0 then for i=0, count-1 do begin
point_lun, lun, ndx[i].fptr
if ndx[i].npts ge 2 then begin
xy=fltarr(2,ndx[i].npts, /NOZERO)
readu,lun,xy
if keyword_set(poly) then $
POLYFILL, xy[1,*], xy[0,*], zvalue, NOCLIP=0, /DATA, _EXTRA=extra $
else PLOTS, xy[1,*], xy[0,*], zvalue, NOCLIP=0, /DATA, _EXTRA=extra
endif
endfor
FREE_LUN, lun
end
PRO Map_Continents, $
USA = kusa, CONTINENTS = kcont, COUNTRIES=kcountries, $
HIRES=khires, FILL_CONTINENTS=kfill_continents, COASTS=kcoasts, $
LIMITS = lim_u, MLINESTYLE = mlinestyle, MLINETHICK = mlinethick, $
SPACING=spacing, COLOR=color, T3D=T3D, ORIENTATION=orientation, $
ZVALUE=zvalue, RIVERS=krivers, $
_EXTRA=extra
;
;
; if fill_continents =1 you get solid polygons
; if fill_continents =2 you get lines
;
if !x.type NE 3 THEN message,'Map transform not established.'
; Map_continents keyword defaults:
cont = keyword_set(kcont)
usa = keyword_set(kusa)
rivers = keyword_set(krivers)
coasts = keyword_set(kcoasts)
countries = keyword_set(kcountries)
hires = keyword_set(khires)
if n_elements(kfill_continents) then fill_continents=kfill_continents $
else fill_continents = 0
if (usa+countries+coasts+rivers eq 0) and n_elements(kcont) eq 0 then cont = 1
if n_elements(zvalue) eq 0 then zvalue = 0.
if n_elements(lim_u) eq 4 then l = lim_u $
else if !map.ll_box(0) ne !map.ll_box(2) or $
!map.ll_box(1) ne !map.ll_box(3) then l = !map.ll_box $
else l = [-90., -360., 90., 360.]
latmin = l(0) & lonmin = l(1)
latmax = l(2) & lonmax = l(3)
;WHY do we have so many ways of expressing a rectangle??
bounds = [lonmin, latmin, lonmax, latmax]
;
; Process the _EXTRA for graphics keywords. Normally the _EXTRA
; values overwrite the input values, but not for maps.
;
if n_elements(mlinestyle) then $
map_struct_append, extra, 'LINESTYLE', mlinestyle
if n_elements(mlinethick) then $
map_struct_append, extra, 'THICK', mlinethick
if n_elements(spacing) and (fill_continents eq 2) then $
map_struct_append, extra, 'SPACING', spacing
if n_elements(color) then $
map_struct_append, extra, 'COLOR',color
if n_elements(orientation) and (fill_continents eq 2)then $
map_struct_append, extra, 'ORIENTATION', orientation
if n_elements(t3d) then map_struct_append, extra,'t3d',t3d
; Process line-filled continents:
if fill_continents eq 2 then map_struct_append, extra, 'LINE_FILL', 1
; if n_tags(extra) gt 0 then help, /st, extra ;Debugging
ij = 0 ;Default = continents only
if rivers ne 0 then begin ;Rivers
map_do_segments, ['rlow', 'rhigh'], 'Rivers', hires, bounds, zvalue, extra
endif ;Rivers
if countries ne 0 then begin ;*** Countries ****
map_do_segments, ['blow', 'bhigh'], 'Boundaries', hires, bounds, $
zvalue, extra
endif ;countries
if coasts ne 0 then begin
map_do_segments, ['clow', 'chigh'], 'Coasts', hires, bounds, zvalue, extra
endif ;Coasts
if cont ne 0 or fill_continents ne 0 then begin
map_do_segments, ['plow', 'phigh'], 'Continents', $
hires, bounds, zvalue, extra, POLYFILL=fill_continents ne 0
endif ;continents
if usa ne 0 then begin ;States in USA, a different file
if cont then ij = 2 else ij = 1
map_file=FILEPATH('supmap.dat',subdir=['resource','maps'])
openr, lun, /get, map_file,/xdr,/stream
npts = 0L
; cont us_only both
fbyte = [ 0, 71612L, 165096L]
nsegs = [ 283, 325, 594 ]
point_lun, lun, fbyte[ij]
for i=1,nsegs[ij] do begin ;Draw each segment
READU, lun, npts,maxlat,minlat,maxlon,minlon
npts = npts / 2 ;# of points
xy = fltarr(2,npts)
READU, lun, xy
if (maxlat lt latmin) or (minlat gt latmax) then goto,skipit
if ((maxlon lt lonmin) or (minlon gt lonmax)) then BEGIN
if (lonmax gt 180. and maxlon + 360. ge lonmin) then goto, goon
goto, skipit
ENDIF
goon: plots,xy[1,*],xy[0,*],zvalue,NOCLIP=0,_EXTRA=extra,/data
skipit:
endfor
FREE_LUN, lun
endif ;USA
end